<nav class="navbar navbar-expand-lg navbar-dark bg-primary">
  <div class="container">
    <a class="navbar-brand" href="{{ url_for('index') }}">KeepRun</a>
    <button
      class="navbar-toggler"
      type="button"
      data-bs-toggle="collapse"
      data-bs-target="#navbarNav">
      <span class="navbar-toggler-icon"></span>
    </button>
    <div class="collapse navbar-collapse" id="navbarNav">
      <ul class="navbar-nav me-auto">
        <li class="nav-item">
          <a class="nav-link" href="{{ url_for('index') }}">首页</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{{ url_for('health_plan') }}">健康计划</a>
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{{ url_for('health_knowledge') }}"
            >健康知识</a
          >
        </li>
        <li class="nav-item">
          <a class="nav-link" href="{{ url_for('community') }}">社区互动</a>
        </li>
      </ul>
      <div class="d-flex">
        {% if current_user.is_authenticated %}
        <div class="dropdown">
          <button
            class="btn btn-light dropdown-toggle"
            type="button"
            id="userDropdown"
            data-bs-toggle="dropdown"
            aria-expanded="false">
            <i class="bi bi-person-circle"></i> {{ current_user.username }}
          </button>
          <ul
            class="dropdown-menu dropdown-menu-end"
            aria-labelledby="userDropdown">
            <li>
              <a class="dropdown-item" href="{{ url_for('user_info') }}"
                ><i class="bi bi-person"></i> 个人信息</a
              >
            </li>
            <li><hr class="dropdown-divider" /></li>
            <li>
              <a class="dropdown-item" href="{{ url_for('logout') }}"
                ><i class="bi bi-box-arrow-right"></i> 退出登录</a
              >
            </li>
          </ul>
        </div>
        {% else %}
        <a href="{{ url_for('login') }}" class="btn btn-light me-2">登录</a>
        <a href="{{ url_for('register') }}" class="btn btn-outline-light"
          >注册</a
        >
        {% endif %}
      </div>
    </div>
  </div>
</nav>
